const dao = require('../../common/dao/bancor');
const api = require('../../common/api');

module.exports = {
    /*
     * 投注列表（含是否中奖）
     */
    bancorList: async function (ctx) {
        if (!api.isset(ctx.request.query, ["pageNo", "pageSize"])) {
            ctx.request.query.pageNo = 1;
            ctx.request.query.pageSize = 15;
        }
        let by = {
            orderBy: {
                k: "a.timestamp",
                v: "desc"
            },
        };
        let fields = [
            "a.from", "a.to", "a.value", "a.amount", "a.timestamp",
            "b.amount as bMount",
        ];
        ctx.body = await dao.bancorList(ctx.request.query, fields, by).then(async (data) => {
            return api.apiExport(data, 0);
        }).catch((e) => {
            console.log(e);
            return api.apiError(e.toString());
        });
    },
};